Repository navigation
Disable text conversion in empty-tree index diffs - #2359
Merged
Merged
Conversation
`IndexFile.diff()` compares the index to the empty tree through `git diff --cached`. Git enables text conversion by default in porcelain `git diff`, as documented in `Documentation/diff-options.adoc`. The direct empty-tree path lacked the flag used by `Diffable.diff`. Pass `--no-textconv` for raw and patch output so this path follows GitPython's existing diff safety behavior. The command-argument regression failed for both empty-tree spellings and both output modes before the fix. The index, diff and CLI safety suites passed with 187 tests and two skips on each backend. Agent-Model: unknown
Contributor
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change disabling text conversion in empty-tree index comparisons.
No open issues 🎉
What changed in this PR
This PR makes empty-tree comparisons in IndexFile.diff() disable repository-configured text conversion, matching the existing behavior of Diffable.diff.
Changes:
- Adds
--no-textconvto the empty-tree diff command for raw and patch output. - Adds four regression cases covering both empty-tree arguments and both output modes.
| File | Description |
|---|---|
test/test_cli_safety.py |
Verifies empty-tree index diffs pass --no-textconv in all four cases. |
git/index/base.py |
Disables text conversion for empty-tree index comparisons. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by Codex.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Motivation
Library-owned diffs should produce raw results and patches without invoking repository-configured text conversion programs. A review of the diff entry points found that
IndexFile.diff()compares against the empty tree usinggit diff --cached, which enables text conversion by default.The empty-tree path now passes
--no-textconvfor raw and patch output, matching the existing behavior ofDiffable.diff.Validation
The four regression cases failed before the fix and now pass. They cover both empty-tree arguments and both output modes. The index, diff, and CLI safety test modules passed on each backend with 187 tests and two skips.